#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define OK 1
#define ERROR 0
#define max 100
#define ElemType int
typedef struct
{
	int *elem;
	int length;
}List;

void InitList_Sq(List &l)
{
l.elem=new int [max];
l.length=0;
}

void shuru(List &l,int n)
{

    for(int i=0;i<n;i++)
    {
       scanf("%d",&l.elem[i]);
      //cin >>l.elem[i];
    }
   l.length=n;
}
void MergeList_Sq(List la,List lb,List &lc)
{
    lc.length=la.length+lb.length;
    lc.elem=new int[lc.length];
   int* pc=lc.elem;
   int* pa=la.elem;
   int* pb=lb.elem;
   int* pa_last=la.elem+la.length-1;
    int* pb_last=lb.elem+lb.length-1;
    while((pa<=pa_last)&&(pb<=pb_last))
    {
        if(*pa<=*pb)
             *pc++=*pa++;
        else
            *pc++=*pb++;
    }
    while(pa<=pa_last)
        *pc++=*pa++;
    while(pb<=pb_last)
        *pc++=*pb++;

}

int main()
{
    List la,lb,lc;
    int n,m,i,j;
    InitList_Sq(la);
    InitList_Sq(lb);
    InitList_Sq(lc);
    cin>>n;
    shuru(la,n);
    cin>>m;
    shuru(lb,m);
    MergeList_Sq(la,lb,lc);


    printf("List A:");
     for(i=0;i<=la.length-1;i++)
            printf("%d ",la.elem[i]);
      printf("\n");
    printf("List B:");
     for(i=0;i<=lb.length-1;i++)
            printf("%d ",lb.elem[i]);
         printf("\n");
         printf("List C:");
     for(i=0;i<=lc.length-1;i++)
            printf("%d ",lc.elem[i]);

    return 0;
}
